package com.billiards.controller;

import com.billiards.entity.Ball;
import com.billiards.entity.BallAppt;
import com.billiards.service.BallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class BallController {
    @Autowired
    private BallService ballService;

    @RequestMapping("/getBallList")
    public List<Ball> getBallList(){
        return ballService.getBallList();
    }
    @GetMapping("/getBallballname")
    public List<Ball> getBallballname (String ballname){
        return ballService.getBallballname(ballname);
    }

    @PostMapping("/updateBall")
    public void updateBallAppt(@RequestBody Ball ball){
        System.out.println("==================");
        System.out.println(ball);
        ballService.updateBall(ball);
    }

    @PostMapping("/addBall")
    public int addAppt(@RequestBody Ball ball){

        System.out.println("===========");
        System.out.println(ball);
        return ballService.addBall(ball);
    }

    @GetMapping("/deleteBall")
    public int deleteBall(int id){
        return ballService.deleteBall(id);
    }
    //查找已预约
    @GetMapping("/getYesBallState")
    List<Ball> getYesBallState(String state){
        return ballService.getYesBallState(state);
    }


    //    查找未预约
    @GetMapping("/getNoBallState")
    List<Ball> getNoBallState(String state){
        return ballService.getNoBallState(state);
    }




}
